#pragma once
#include <iostream>
#include <functional>

int add(int a, int b)
{
	return a + b;
}

struct Add
{
	int operator()(int a, int b)
	{
		return a + b;
	}
};

void test1()
{
	auto lambda1 = [](int a, int b) {return a + b;};

	auto addbind = std::bind(add, std::placeholders::_1, std::placeholders::_2);
	auto Addbind = std::bind(Add(), std::placeholders::_1, std::placeholders::_2);
	auto lambda1bind = std::bind(lambda1, std::placeholders::_1, std::placeholders::_2);
	auto lambda2bind = std::bind([](int a, int b) {return a + b;}, std::placeholders::_1, std::placeholders::_2);

	int a = 8, b = 4;
	int a1 = addbind(a, b);
	int a2 = Addbind(a, b);
	int a3 = lambda1bind(a, b);
	int a4 = lambda2bind(a, b);
	std::cout << a1 << std::endl;
	std::cout << a2 << std::endl;
	std::cout << a3 << std::endl;
	std::cout << a4 << std::endl;

	std::cout << lambda1(a, b) << std::endl;

}

void test2()
{
	auto func1 = [](double rate, double money, int year)//->double
		{
			while (year--)
			{
				money += rate * money;
			}
			return money;
		};
	//double rate1;
	//std::cin >> rate1;
	//double value = func1(rate1, 10000, 1);
	auto bind1 = std::bind(func1, 0.0135, 200000, 3);
	double value = bind1();
	std::cout << value << std::endl;



}
int main()
{
	test2();
	return 0;
}


